package org.example.lottery_system.dao.mapper;

import jakarta.validation.constraints.NotBlank;
import org.apache.ibatis.annotations.*;
import org.example.lottery_system.dao.dataobject.Encrypt;
import org.example.lottery_system.dao.dataobject.UserDO;

@Mapper
public interface UserMapper {
    @Select("select count(*) from user where email =#{email}")
    int countByMail(@Param("email") String mail);

    @Select("select count(*) from user where  phone_number =#{phoneNumber}")
    int countByPhone(@Param("phoneNumber")Encrypt phoneNumber);//为什么会调用handler

    @Insert("insert into user(user_name,email,phone_number,password,identity)" +
    " values (#{userName},#{email},#{phoneNumber},#{password},#{identity})")

    @Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
    void insert(UserDO userDO);

    @Select("select * from user where email = #{email}")
    UserDO selectByMail(@Param("email") String email);
@Select("select * from user where phone_number = #{phoneNumber}")
    UserDO selectByPhoneNumber(@Param("phoneNumber") Encrypt phoneNumber);

@Select("select * from user where identity = #{identity} order by desc")
    void selectUserListByIdentity(@Param("identity") String identity);
}
